<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% 
		String path = request.getContextPath();    
    %>
<html lang="en">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="path" value="${pageContext.request.contextPath}" ></c:set>
<script type="text/javascript" src="${path }/js/jquery-3.6.0.min.js""></script>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>我的收藏</title>

    <link rel="icon" type="image/png" href="<%= path %>/assets/images/favicon-32x32.png">

    <link rel="stylesheet" href="<%= path %>/assets/main/css/fonts.css">
    <link rel="stylesheet" href="<%= path %>/assets/main/css/style.css">
</head>

<body>
    <div id="main-wrapper" class="show">
        <div class="nav-header">
            <div class="brand-logo">
                <a href="${path }/web/index.jsp"><img class="brand-title" src="<%= path %>/assets/images/logo.png" alt=""></a>
            </div>
        </div>
        <aside class="left-panel nicescroll-box">
            
           <nav class="navigation">
                <ul class="list-unstyled main-menu">
                    <li class="has-submenu">
                        <a href="${path }/MyCollectionController?action=getMyCollection">
                            <i class="fas fa-th-large"></i>
                            <span class="nav-label">我的收藏</span>
                        </a>
                    </li>
                    <li class="has-submenu">
                        <a href="${path }/PostController?action=show">
                            <i class="fas fa-calendar-plus"></i>
                            <span class="nav-label">我的发布</span>
                        </a>
                    </li>
                    <li class="has-submenu">
                        <a href="${path }/UpdatePasswordController?action=changeuserpass">
                            <i class="fas fa-chart-pie"></i>
                            <span class="nav-label">修改密码</span>
                        </a>
                    </li>
                    <li class="has-submenu">
                        <a href="${path}/UpdateUserinfoCenterController?action=UpdateUserinfoCenterById">
                            <i class="fas fa-cog"></i>
                            修改个人信息
                        </a>
                    </li>
                    <li class="has-submenu">
                          <a href="${path}/PostNumberLikesController?action=postNumberLikes">
                            <i class="fas fa-cog"></i>
          	获赞               
                        </a>
                    </li>
                     <li class="has-submenu">
                          <a href="${path}/CommentReplyController?action=findAll">
                            <i class="fas fa-cog"></i>
          	我的帖子               
                        </a>
                    </li>
                </ul>
            </nav>
            
            <div class="sidebar-widgets">
                <div class="top-sidebar box-shadow mx-25 m-b-30 p-b-20 text-center">
                <img src="<%= path %>/assets/images/appointement.svg" class="side-img" alt="img">
                </div>
                <div class="copyright text-center">
                    <p class="mb-0"> 中国航天</p>
                    <p class="mb-0"> © 2021 </p>
                </div>
            </div>
        </aside>




       <jsp:include page="/inc/signter.jsp"></jsp:include>



        <div class="content-body">
            <div class="warper container-fluid">
                <div class="row page-titles mx-0">
                    <div class="col-lg-12 p-md-0">
                        <h4 class="text-primary">欢迎进入个人中心</h4>
                    </div>
                </div>
                <div class="new-patients main_container">
                    <div class="row">
                        <div class="col-sm-6 col-xl-3 col-lg-6">
                            <div class="widget card card-primary">
                                <div class="card-body" style="background-color:#0d6efd;border-radius:5px;">
                                    <div class="media text-center">
                                        <span>
                                            <i class="fas fa-calendar-check fa-2x"></i>
                                        </span>
                                        <div class="media-body">
                                            <span class="text-white">收藏帖子数量</span>
                                            <h3 class="mb-0 text-white">${count}</h3>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card shadow">
                                <div class="card-header">
                                    <h4 class="card-title">已收藏</h4>
                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table id="example1" class="display nowrap">
                                            <thead>
                                                <tr>
                                                    <th>标题</th>
                                                    <th>发布人</th>
                                                     <th>内容</th>
                                                     <th>发布时间</th> 
                                                    <th>取消收藏</th>
                                                   
                                                    
                                                </tr>
                                            </thead>
                                             <c:forEach items="${collections }" var="collections">
                                            <tbody>
                                              <tr id="row${collections.id}">
                                                    <td>${collections.post.title}</td>
                                                    <td>${collections.userinfo.username }</td>
                                                    <td><a href="${path }/MyCollectionController?action=contentDisplay&id=${collections.id}">查看详情</a></td>
                                                    <td><fmt:formatDate value="${collections.post.pubTime}" pattern="yyyy年MM月dd日 HH:mm:ss" /></td>
                                                    <td class="text-start">
                                                        <button onclick="delCollection(${collections.id})">取消收藏</button>
                                                    </td>
                                                    <td>
                                                    </td>
                                                </tr>
                                               
                                                
                                                                                      
                                            </tbody>
                                            </c:forEach>
                                        </table>
                                        
                                    </div>
                                   
                                   
                                    <c:forEach begin="1" var="i" end="${count/2+(count%2==0?0:1)}">
                                    	<div style="float:left;margin-left:5px;border:1px solid gray;background-color:#f2eada;text-align:center;height:20px;width:20px">
                                    	 <a style="color:blue" href="${path }/MyCollectionController?action=getMyCollection&pageNum=${i}">${i}</a>
                                     	</div>
                                    </c:forEach> 
                                  
                                    
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="footer">
            <div class="copyright">
                <p class="mb-0">Copyright ©&中国航天  &amp;2021
                </p>
            </div>
        </div>
    </div>

   
    <script src="<%= path %>/assets/plugins/popper/popper.min.js"></script>
    <script src="<%= path %>/assets/plugins/bootstrap/js/bootstrap.js"></script>
    <script src="<%= path %>/assets/plugins/moment/moment.min.js"></script>
    <script src="<%= path %>/assets/plugins/daterangepicker/daterangepicker.min.js"></script>
    <script src="<%= path %>/assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<%= path %>/assets/js/init-tdatatable.js"></script>
    <script src="<%= path %>/assets/plugins/chart/chart/Chart.min.js"></script>
    <script src="<%= path %>/assets/js/charts-custom.js"></script>
    <script src="<%= path %>/assets/js/toggleFullScreen.js"></script>
    <script src="<%= path %>/assets/js/main.js"></script>

</body>

</html>

<script type="text/javascript">
     
    	  function delCollection(id){
    		    //询问对话框
    			var f = confirm("您确定要取消收藏吗?");
    			if(f==true)
    			{
	    			var url = "${path}/MyCollectionController?action=delete&id="+id;
	    			$.get(url,function(){
	    				$("#row"+id).remove();
	    				//页面刷新
	    				location.href=location.href;
	    			});
    			}
    		}
    
</script>
